<?php
/**
 * Copyright (c) [2019] [吴跃忠]
 * [selibra] is licensed under the Mulan PSL v1.
 * You can use this software according to the terms and conditions of the Mulan PSL v1.
 * You may obtain a copy of Mulan PSL v1 at:
 * http://license.coscl.org.cn/MulanPSL
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
 * PURPOSE.
 * See the Mulan PSL v1 for more details.
 */

namespace LeoMQ\Annotations;

use \Attribute;
use LeoMQ\RealizesCollection;
use Selibra\Di\AnnotationConfigure;
use Selibra\Di\AnnotationExecEntity;
use Selibra\Di\Annotations\Protocol\SelibraAnnotationInterface;
use Selibra\Tools\Console;

/**
 * 消费者实现类的注解类
 * 使用这个注解类来构建一个消费者实现类，消费者实现类必须实现于 Intf\ConsumerInterface 接口
 * Class ConsumerRealize
 * @package LeoMQ\Annotations
 */
#[Attribute(Attribute::TARGET_CLASS)]
final class ConsumerRealize implements SelibraAnnotationInterface
{
    /**
     * @var string
     */
    protected string $key;

    public function __construct($key)
    {
        $this->key = $key;
    }

    /**
     * 执行
     * @param AnnotationExecEntity $annotationExecEntity
     * @return mixed|void
     */
    public function exec(AnnotationExecEntity &$annotationExecEntity)
    {
        $collection = new RealizesCollection();
        $collection['consumer:' . $this->key] = $annotationExecEntity->getClass();
    }

    /**
     * @param AnnotationConfigure $annotationConfigure
     * @return mixed|void
     */
    public function configure(AnnotationConfigure $annotationConfigure)
    {
        // TODO: Implement configure() method.
    }
}